#include <iomanip>
#include "print.h"
#include "func.h"

//функция вывода результата в файл                                                                                                                          
void print_res (std::ofstream &out, std::valarray<double> grad, std::valarray<double> w,
                double hw, file_names& Fnames, input& data) {
  for (unsigned i=0; i<w.size(); i++) {
    out << std::setiosflags(std::ios::right)
        << std::setprecision(10)  << std::setiosflags(std::ios::fixed |std::ios::showpoint)
        << std::setw(13) << std::setiosflags(std::ios::right) << w[i] << " ";
  }
  out << std::setw(3);
  out << " ";

  out << "I= " << std::setiosflags(std::ios::right) << func(w,Fnames,data);
  out << std::setw(3);
  out << " ";

  out << "F0= " << std::setiosflags(std::ios::right) << data.F;
  out << std::setw(3);
  out << " ";

  for (unsigned i=0; i<grad.size(); i++) {
    out << " F'w[" << i << "]= " << std::setiosflags(std::ios::right)
        << std::setiosflags(std::ios::fixed |std::ios::showpoint) << std::setprecision(10)
        << std::setw(13) << std::setiosflags(std::ios::right) << grad[i];
  }
  out << std::setw(3);
  out << " ";

  out << "b0= " << std::setiosflags(std::ios::right) << data.beta0;
  out << std::setw(3);
  out << " ";

  for (unsigned i=0; i<data.m; i++) {
    out << " b1[" << i << "]= " << std::setiosflags(std::ios::right)
        << std::setiosflags(std::ios::fixed |std::ios::showpoint) << std::setprecision(10)
        << std::setw(13) << std::setiosflags(std::ios::right) << data.beta1[i];
  }
  out << std::setw(3);
  out << " ";

  for (unsigned i=0; i<data.m; i++) {
    out << " b2[" << i << "]= " << std::setiosflags(std::ios::right)
        << std::setiosflags(std::ios::fixed |std::ios::showpoint) << std::setprecision(10)
        << std::setw(13) << std::setiosflags(std::ios::right) << data.beta2[i];
  }
  out << std::setw(3);
  out << " ";

  out << "h= " << std::setw(13) << std::setiosflags(std::ios::right) << hw;
  out << std::endl;
}


